package com.zhl.emp_manage.mapper;

import com.zhl.emp_manage.entity.Dept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface DeptMapper {
    //查询所有部门
    @Select("select * from dept")
    List<Dept> getAllDept();

    //根据id查询部门信息
    @Select("select * from dept where id=#{id}")
    Dept getByDeptNo(Integer id);

    //新增部门
    @Insert("insert into dept (id,dept_name,dept_local,dept_num) values (#{id},#{deptName},#{deptLocal},#{deptNum})")
    boolean addDept(Dept dept);

    //修改部门信息
    @Update("update dept set dept_name=#{deptName},dept_local=#{deptLocal},dept_num=#{deptNum} where id=#{id}")
    boolean updateDept(Dept dept);

    //根据id删除部门信息
    @Delete("delete from dept where id=#{id}")
    boolean deleteDept(Integer id);

    //模糊查询
    @Select("select * from dept where dept_name like CONCAT('%',#{deptName},'%')")
    List<Dept> getDeptLike(String name);
}
